home *** CD-ROM | disk | FTP | other *** search
/ YPA: Your Privacy Assured / YPA.ISO / other_goodies / utilities / powercache37115.lha / Documentation / ARexx Examples / test.rexx < prev    next >
OS/2 REXX Batch file  |  1994-04-02  |  7KB  |  211 lines

  1. /* $VER: PowerCacheTest.rexx 37.2 (8.1.93)
  2.  *
  3.  * This script illustrates some of the features of PowerCache, and how
  4.  * to use ARexx to control the program. Not all commands are tested. For
  5.  * a complete description of PowerCache's ARexx interface, please refer
  6.  * to PowerCacheARexx.guide.
  7.  *
  8.  * Copyright (C) 1993, 1994 by Michael Berg
  9.  * All Rights Reserved
  10.  */
  11.  
  12. /* Make sure we get results back from ARexx */
  13. OPTIONS RESULTS
  14.  
  15. /* Make sure PowerCache is on line */
  16. IF ~SHOW(P,'POWERCACHE') THEN DO
  17.     SAY 'PowerCache is not running -- Start the program and run this script again'
  18.     EXIT
  19. END
  20.  
  21. /* Talk to him */
  22. ADDRESS 'POWERCACHE'
  23.  
  24. /* Manifest constants */
  25. NL  = '0a'x
  26. TAB = '09'x
  27.  
  28. SAY '╖ Testing VERSION Command:' || NL
  29. Version
  30. SAY TAB || '╖ PowerCache returns "' || Result || '"'
  31. CALL PollReturn
  32.  
  33. SAY '╖áTesting CACHEABLE Command:' || NL
  34.  
  35. Cacheable STEM Result.
  36.  
  37. SAYáTAB || 'List of Cacheable devices:' NL
  38. DO i = 0 TO Result.device.count-1
  39.     SAY TAB || i'.' Result.device.i Result.devname.i 'unit' Result.unit.i
  40. END
  41.  
  42. CALL PollReturn
  43.  
  44. SAY NL || '╖ Testing LISTCURRENTLYCACHED Command:' NL
  45. ListCurrentlyCached STEM Result.
  46.  
  47. SAY TAB || 'Device' || TABá|| 'Organization' || TAB || 'Type' || TAB || 'Algo' NL
  48.  
  49. DO i = 0 TO Result.device.count-1
  50.     SAY TAB || i'.'        Result.device.i,
  51.                     '  '|| Result.sets.i Result.lines.i result.prefetch.i,
  52.                     TAB || Result.type.i,
  53.                     TAB || Result.algorithm.i
  54.  
  55.     /* Also available, but omitted for simplicity:
  56.      *
  57.      * Result.purgetime.i
  58.      * Result.freeafterpurge.i 
  59.      * Result.cachebuffer.i 
  60.      * Result.buffersize.i
  61.      * Result.overhead.i
  62.      *
  63.      * (Please refer to PowerCacheARexx.guide for an explanation of these
  64.      * variables)
  65.      */
  66. END
  67.  
  68. CALL PollReturn
  69.  
  70. /* We're going to use DF0: as an example in the following sections. So we
  71.  * have to make sure the user is not already caching this device (and remove
  72.  * it if he is)
  73.  */
  74.  
  75. GetCacheInfo 'DF0:'
  76.  
  77. IF RC = 0 THEN DO
  78.     RemoveCache 'DF0:'
  79.     SAY NL || '(Removed Cache on DF0: to simplify the following ARexx example'||NL||'code sections)'
  80.     CALL PollReturn
  81. END
  82.  
  83. SAY '╖ Testing ADDCACHE Command' || NL
  84.  
  85. AddCache 'DF0:' 8 32 4 'R/W' 'LRU' 2 'ANY' 'STATHOTKEY "shift control 0"'
  86.  
  87. IF RC ~= 0 THEN DO
  88.   SAY TAB || 'Could not add a 512k cache to DF0:' || NL,
  89.       TAB || 'PowerCache says: "' || RC2 || '"'
  90. END
  91. ELSE DO
  92.    SAY TAB || 'Successfully added a 8 x 32 x 4 cache (512k) to DF0:'
  93.  
  94.    CALL PollReturn
  95.  
  96.    SAY TAB || '╖ Testing GETCACHEINFO Command on DF0:' || NL
  97.    GetCacheInfo 'DF0:' STEM Result.
  98.    IF RC = 0 THEN DO
  99.        SAY       TAB || TAB || 'Sets       =' Result.sets,
  100.            NL || TAB || TAB || 'Lines      =' Result.lines,
  101.            NL || TAB || TAB || 'Prefetch   =' Result.prefetch || NL,
  102.            NL || TAB || TAB || 'Type       =' Result.type,
  103.            NL || TAB || TAB || 'Algorithm  =' Result.algorithm,
  104.            NL || TAB || TAB || 'Purgetime  =' Result.purgetime,
  105.            NL || TAB || TAB || 'FreePurge?  ' Result.freeafterpurge,
  106.            NL || TAB || TAB || 'StatHotKey =' Result.stathotkey || NL,
  107.            NL || TAB || TAB || 'CacheBuffer =' Result.cachebuffer,
  108.            NL || TAB || TAB || 'BufferSize  =' Result.buffersize,
  109.            NL || TAB || TAB || 'Overhead    =' Result.overhead
  110.    END
  111.    ELSE SAY TAB || TAB || 'Could not GETCACHEINFO for DF0:' || NL,
  112.             TAB || TAB || 'PowerCache says: "' || RC2 || '"'
  113.  
  114.    CALL PollReturn
  115.  
  116.    SAY '╖ Showing statistics for DF0: ...'
  117.  
  118.    ShowStats 'DF0:'
  119.  
  120.    IF RESULT == 'ON' THEN
  121.       SAY TAB || 'Statistics window was already open' NL
  122.    ELSE
  123.       SAY TAB || 'Statistics window was opened' NL
  124.  
  125.    Call PollReturn
  126.  
  127.    SAY '╖ Closing the statistics window again...' NL
  128.        HideStats 'DF0:'
  129.  
  130.    Call PollReturn
  131.  
  132.    SAY TAB || '╖ Testing REMOVECACHE Command'
  133.    RemoveCache 'DF0:'
  134.    IF RC ~= 0 THEN DO
  135.        SAY TAB || TAB || 'Could not remove cache on DF0:' || NL,
  136.        TAB || TAB || 'PowerCache says: "' || RC2 || '"'
  137.    END
  138.    ELSE SAY TAB || TAB || 'Successfully removed cache from DF0:'
  139. END
  140.  
  141. CALL PollReturn
  142.  
  143. SAY '╖ Testing GETDEVICEINFO Command for DF0:' || NL
  144.  
  145. GetDeviceInfo 'DF0:' STEM Result.
  146. IF RC == 0 THEN DO
  147.     SAY TAB || 'Logical Drive            =' Result.logicaldrive || NL,
  148.         TAB || 'Devicename               =' Result.devicename || NL,
  149.         TAB || 'Unit                     =' Result.unit || NL,
  150.         TAB || 'Task TCB                 =' Result.tasktcb || NL,
  151.         TAB || 'Sectorsize               =' Result.sectorsize || NL,
  152.         TAB || 'Surfaces                 =' Result.surfaces || NL,
  153.         TAB || 'Blocks per Track         =' Result.blockspertrack || NL,
  154.         TAB || 'Capacity                 =' Result.capacity || NL,
  155.         TAB || 'Reserved (start)         =' Result.reservedstart || NL,
  156.         TAB || 'Reserved (end)           =' Result.reservedend || NL,
  157.         TAB || 'Interleave               =' Result.interleave || NL,
  158.         TAB || 'Low Cylinder             =' Result.lowcyl || NL,
  159.         TAB || 'High Cylinder            =' Result.highcyl || NL,
  160.         TAB || 'Initial DOS Buffers      =' Result.initialdosbuffers || NL,
  161.         TAB || 'Buffer Memory Type       =' Result.bufmemtype || NL,
  162.         TAB || 'Max Transfer per Request =' Result.maxtransfer || NL,
  163.         TAB || 'Address Mask             =' Result.mask || NL,
  164.         TAB || 'Boot Priority            =' Result.bootpri || NL,
  165.         TAB || 'File System              =' Result.filesystem || NL,
  166.         TAB || 'Boot Blocks              =' Result.bootblocks || NL
  167. END
  168. ELSE SAY TAB || 'Could not GETDEVICEINFO for DF0:' || NL,
  169.          TAB || 'PowerCache says: "' || RC2 || '"'
  170.  
  171. CALL PollReturn
  172.  
  173. SAY '╖ Testing SHOW/HIDE' || NL
  174. SAY TAB || '╖ SHOW'
  175. Show
  176. CALL PollReturn
  177. SAY TABá||á'╖ HIDE'
  178. Hide
  179. CALL PollReturn
  180. Show
  181.  
  182. SAY '╖ Testing SETENABLEKEY'
  183.  
  184. SetEnableKey '"control shift alt b"'
  185. IF RC = 0 THEN DO
  186.     SAY TAB || 'Managed to change the hotkey from "' || Result || '"' || NL,
  187.         TAB || 'to "control shift alt b".'
  188.  
  189.     /* Double quoting is necessary - and this is how you do it */
  190.     OldKey = '"' || Result || '"'
  191.  
  192.     CALL PollReturn
  193.  
  194.     SAY TAB || 'Restoring hotkey to original setting'
  195.     SetEnableKey OldKey
  196.  
  197.     IF RC ~= 0 THEN SAY TAB || 'Failed -- PowerCache says: "' || RC2 || '"'
  198. END
  199. ELSE SAY TAB || 'Could not change hotkey' || NL,
  200.          TAB || 'PowerCache says: "' || RC2 || '"'
  201.  
  202. SAY NL || 'This concludes the demonstation. For a complete description' || NL,
  203.           'of the ARexx interface, please consult the ARexx guide in the' || NL,
  204.           'parent directory. You can close the window now if you like.'
  205.  
  206. EXIT
  207.  
  208. PollReturn:
  209.     SAY NL || 'PRESS RETURN'
  210.     PULL Anything
  211.